package com.heima.article.controller.v1;

import com.heima.article.service.IApArticleService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.dtos.SaveArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController {
    @Autowired
    private IApArticleService apArticleService;
    /**
     * 文章分也查询------推荐
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleDto dto){
        ResponseResult responseResult = apArticleService.load(dto, 3);
        return responseResult;
    }

    /**
     * 查询更多,type=2
     * @param dto
     * @return
     */
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleDto dto){
        ResponseResult responseResult = apArticleService.load(dto, 2);
        return responseResult;
    }

    /**
     * 查询更新,type=1
     * @param dto
     * @return
     */
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleDto dto){
        ResponseResult responseResult = apArticleService.load(dto, 1);
        return responseResult;
    }

    /**
     * 提交审核---保存文章三剑客
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveArticle3(@RequestBody SaveArticleDto dto){
        return apArticleService.saveArticle3(dto);
    }

}
